﻿using System;
using System.Text;
using SuperSocket.Common;
using SuperSocket.Facility.Protocol;
using SuperSocket.SocketBase.Protocol;
using Newtonsoft.Json;
using System.Collections;
using Newtonsoft.Json.Linq;

namespace UFrameWork
{
    /// <summary>
    /// 接收过滤器
    /// </summary>
    public class UReceiveFilter : TerminatorReceiveFilter<StringRequestInfo>
    {
        /// <summary>
        /// 结束标记
        /// </summary>
        public static readonly string EndFlag = "\r$\n";

        private static readonly byte[] EndBytes = Encoding.UTF8.GetBytes(EndFlag);

        private static string[] param = new string[] { };

        public UReceiveFilter()
            : base(EndBytes)
        { 
        
        }

        protected override StringRequestInfo ProcessMatchedRequest(byte[] readBuffer, int offset, int length)
        {
            string key = "JsonMsgCmd";
            string msg = Encoding.UTF8.GetString(readBuffer, offset, length);
            return new StringRequestInfo(key, msg, param);
        }
    }
}
